﻿var vm = new Vue({
    el: "#PAGE_MODEL",
    data: {
        //查询关联明细表的关键字
        keyword: '',

        WebSite:"",

        //多条信息
        VmGXBIDModels: [],

        //单个类
        VmGXBIDModel:
        {
            //ID
            GId: "",

            //详情标题
            Title: "",

            //详情链接
            Url: "",

            //发布时间
            Time: "",

            //网站标志
            Website: "",

            //网站链接
            WebUrl: "",

            //网站标题
            WebTitle: "",

            //网站栏目
            WebNode:""
        },

        //索引
        pageindex: 0,

        //每页记录数
        pagesize: 10,

        //总页数
        pagecount: 1,

        //分页标志
        pagesizes: [10, 20, 30, 40, 50],

        //当前页
        currentpage: 1,

        //总页数
        total: 0

    },
    methods: {

        //区采购--查询记录列表---handleCurrentChange
        getGXListCurrent: function (index) {
            var self = this;
            self.pageindex = index - 1;
            var ws = "区采购";
            $.ajax({
                url: URLs.URL_QBJ_CG_LIST,
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    keyword: $("#keyword").val(),
                    WebSite: ws,
                    pageindex: self.pageindex,
                    pagesize: self.pagesize
                }),
                contentType: 'application/json; charset=utf-8',
                success: function (data) {
                    if (data.ISOK) {

                        self.VmGXBIDModels = data.VmGXBIDModels;

                        //绑定查询条件
                        self.pageindex = data.PageIndex;
                        self.pagecount = data.PageCount;
                        self.total = data.RecordCount;

                    } else {
                        bootbox.alert("查询信息错误，错误代码：<br />" + data.MESSAGE);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    bootbox.alert("系统运行错误（获取记录列表），错误代码：<br />" + textStatus);
                    $.jqhideloading();
                },
                beforeSend: function () {
                    $.jqshowloading();
                },
                complete: function () {
                    $.jqhideloading();
                }
            });
        },

        //区采购--查询列表--handleSizeChange
        getGXListindex: function () {
            var self = this;
            var ws = "区采购";
            $.ajax({
                url: URLs.URL_QBJ_CG_LIST,
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    keyword: $("#keyword").val(),
                    WebSite: ws,
                    pageindex: self.pageindex,
                    pagesize: self.pagesize
                }),
                contentType: 'application/json; charset=utf-8',
                success: function (data) {
                    if (data.ISOK) {

                        self.VmGXBIDModels = data.VmGXBIDModels;

                        //绑定查询条件
                        self.pageindex = data.PageIndex;
                        self.pagecount = data.PageCount;
                        self.total = data.RecordCount;

                    } else {
                        bootbox.alert("查询信息错误，错误代码：<br />" + data.MESSAGE);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    bootbox.alert("系统运行错误（获取记录列表），错误代码：<br />" + textStatus);
                    $.jqhideloading();
                },
                beforeSend: function () {
                    $.jqshowloading();
                },
                complete: function () {
                    $.jqhideloading();
                }
            });
        },

        //区采购--当前页多少条记录
        handleCurrentChange: function (index) {
            var self = this;
            //选中的第几页
            self.getGXListCurrent(index);
            console.log(index);
        },

        //区采购--每页多少条记录
        handleSizeChange: function (size) {
            var self = this;
            self.currentpage = 1;
            self.pagesize = size;
            self.pageindex = 0;
            self.getGXListindex();
            console.log(size);
        },

        //区采购--查询上一页数据
        pagePrev: function () {
            var self = this;

            if (self.pageindex - 1 >= 0) {
                self.pageindex--;
                self.getGXListindex();
            } else {
                bootbox.alert("已经是第一页了！");
            }
        },

        //区采购--查询下一页数据
        pageNext: function () {
            var self = this;

            if (self.pageindex + 1 < self.pagecount) {
                self.pageindex++;
                self.getGXListindex();
            } else {
                bootbox.alert("已经是最后一页了！");
            }
        },

//-------------------------------------------------------------------------------------- 

        //区招预--查询记录列表---handleCurrentChange
        getGXListCurrent_qzy: function (index) {
            var self = this;
            self.pageindex = index - 1;
            var ws = "区招预";
            $.ajax({
                url: URLs.URL_QBJ_ZY_LIST,
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    keyword: $("#keyword").val(),
                    WebSite: ws,
                    pageindex: self.pageindex,
                    pagesize: self.pagesize
                }),
                contentType: 'application/json; charset=utf-8',
                success: function (data) {
                    if (data.ISOK) {

                        self.VmGXBIDModels = data.VmGXBIDModels;

                        //绑定查询条件
                        self.pageindex = data.PageIndex;
                        self.pagecount = data.PageCount;
                        self.total = data.RecordCount;

                    } else {
                        bootbox.alert("查询信息错误，错误代码：<br />" + data.MESSAGE);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    bootbox.alert("系统运行错误（获取记录列表），错误代码：<br />" + textStatus);
                    $.jqhideloading();
                },
                beforeSend: function () {
                    $.jqshowloading();
                },
                complete: function () {
                    $.jqhideloading();
                }
            });
        },

        //区招预--查询列表--handleSizeChange
        getGXListindex_qzy: function () {
            var self = this;
            var ws = "区招预";
            $.ajax({
                url: URLs.URL_QBJ_ZY_LIST,
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    keyword: $("#keyword").val(),
                    WebSite: ws,
                    pageindex: self.pageindex,
                    pagesize: self.pagesize
                }),
                contentType: 'application/json; charset=utf-8',
                success: function (data) {
                    if (data.ISOK) {

                        self.VmGXBIDModels = data.VmGXBIDModels;

                        //绑定查询条件
                        self.pageindex = data.PageIndex;
                        self.pagecount = data.PageCount;
                        self.total = data.RecordCount;

                    } else {
                        bootbox.alert("查询信息错误，错误代码：<br />" + data.MESSAGE);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    bootbox.alert("系统运行错误（获取记录列表），错误代码：<br />" + textStatus);
                    $.jqhideloading();
                },
                beforeSend: function () {
                    $.jqshowloading();
                },
                complete: function () {
                    $.jqhideloading();
                }
            });
        },

        //区招预--当前页多少条记录
        handleCurrentChange_qzy: function (index) {
            var self = this;
            //选中的第几页
            self.getGXListCurrent_qzy(index);
            console.log(index);
        },

        //区找预--每页多少条记录
        handleSizeChange_qzy: function (size) {
            var self = this;
            self.currentpage = 1;
            self.pagesize = size;
            self.pageindex = 0;
            self.getGXListindex_qzy();
            console.log(size);
        },

        //区找预--查询上一页数据
        pagePrev_qzy: function () {
            var self = this;

            if (self.pageindex - 1 >= 0) {
                self.pageindex--;
                self.getGXListindex_qzy();
            } else {
                bootbox.alert("已经是第一页了！");
            }
        },

        //区招预--查询下一页数据
        pageNext_qzy: function () {
            var self = this;

            if (self.pageindex + 1 < self.pagecount) {
                self.pageindex++;
                self.getGXListindex_qzy();
            } else {
                bootbox.alert("已经是最后一页了！");
            }
        },

    }
});